package top.fyr.config;

import com.weibo.api.motan.config.springsupport.AnnotationBean;
import com.weibo.api.motan.config.springsupport.BasicServiceConfigBean;
import com.weibo.api.motan.config.springsupport.ProtocolConfigBean;
import com.weibo.api.motan.config.springsupport.RegistryConfigBean;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Bean;

/**
 * @description
 * @Author 付阳荣
 * @CreateDate 2018/3/15
 */
@SpringBootConfiguration
public class Config {

	/**
	 * 声明Annotation用来指定需要解析的包名
	 *
	 * @return
	 */
	@Bean
	public AnnotationBean motanAnnotationBean() {
		AnnotationBean motanAnnotationBean = new AnnotationBean();
		motanAnnotationBean.setPackage("top.fyr.service");
		return motanAnnotationBean;
	}

	@Bean(name = "demoMotan")
	public ProtocolConfigBean protocolConfig1() {
		ProtocolConfigBean config = new ProtocolConfigBean();
		config.setDefault(true);
		config.setName("motan");
		config.setMaxContentLength(1048576);
		return config;
	}

	@Bean(name = "registryConfig1")
	public RegistryConfigBean registryConfig() {
		RegistryConfigBean config = new RegistryConfigBean();
		config.setRegProtocol("local");
		return config;
	}

	@Bean
	public BasicServiceConfigBean baseServiceConfig() {
		BasicServiceConfigBean config = new BasicServiceConfigBean();
		config.setExport("demoMotan:8002");
		config.setGroup("testgroup");
		config.setAccessLog(false);
		config.setShareChannel(true);
		config.setModule("motan-demo-rpc");
		config.setApplication("myMotanDemo");
		config.setRegistry("registryConfig1");
		return config;
	}
}
